﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using BE;
using BLL;
using System.ServiceModel.Activation;

namespace GraphService
{
	[ServiceBehavior( InstanceContextMode = InstanceContextMode.Single )]
	[AspNetCompatibilityRequirements( RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed )]
	public class GraphService : IGraphService
	{
		Graph map = new Graph();
		List<Room> rooms = new List<Room>();

		#region IGraphService Members
		public void UpdateGraph()
		{
			VertexWorker vw = new VertexWorker();
			EdgeWorker ew = new EdgeWorker();
			map.UpdateGraph( vw.GetDictionariedVertices(), ew.GetAll() );
		}

		public List<string> getDirections( Room start, Room end )
		{
			List<Edge> l = map.GetPath( start, end );
		return	map.getDirections( l );
		}

		public List<Room> GetRooms()
		{
			return rooms;
			
		}
		
		public void UpdateRooms()
		{
			RoomWorker rw = new RoomWorker();
			rooms = rw.GetAllRooms();
		}
		#endregion
	}
}
